<template>
    <div class="admin-header head">
        <el-button type="text" class="admin-size-button" @click="onGoBack">

            <div v-show="$local.isCollapse">
                <i class="fa fa-angle-double-right"></i>
            </div>
            <div v-show="!$local.isCollapse">
                <i class="fa fa-angle-double-left"></i>
            </div>
        </el-button>
        <div class="search">
            <admin-search @change="onSearchChange"></admin-search>
        </div>
    </div>

</template>
<style scoped>
    .search {
        padding-right: 10px;
    }

    .head {
        justify-content: space-between;
    }
</style>
<script type="ts">
    import {Vue, Component} from "vue-property-decorator";
    import AdminSearch from '@/views/controls/AdminSearch'

    @Component({
        components: {
            AdminSearch
        }
    })
    export default class AdminHeader extends Vue {

        onChangeCollapse() {
            this.$local.SetCollapse(!this.$local.isCollapse);
        }

        onGoBack() {
            this.$router.back();
        }

        onSearchChange(user) {

            if(user.type === 1) {
                this.$router.push({
                    path:`/user/${user.id}`
                })
            }

            if (user.type === 3) {
                this.$router.push({
                    path: `/stars/club/editor/${user.id}`
                })
            }
            if(user.type === 2) {
                this.$router.push(`/stars/${user.id}`)
            }
        }
    }
</script>
